package com.bmps.springcloud.insuredmicroservice;

import com.bmps.springcloud.insuredmicroservice.provider.GracefulShutdownTomcat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;

/**
 * 服务启动类
 * @author luofei
 * @date 2019/6/18 16:36
 **/
@SpringBootApplication(scanBasePackages = {"com.bmps.springcloud"})
public class BmpsNBDemoApplication {

    private static Logger logger = LoggerFactory.getLogger(BmpsNBDemoApplication.class);

    public static void main(String[] args) {
         SpringApplication.run(BmpsNBDemoApplication.class,args);
         logger.error("------------受理服务启动成功------------");
    }

    private final GracefulShutdownTomcat gracefulShutdownTomcat;

    @Autowired
    public BmpsNBDemoApplication(GracefulShutdownTomcat gracefulShutdownTomcat) {
        this.gracefulShutdownTomcat = gracefulShutdownTomcat;
    }

    @Bean
    public ServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
        tomcat.addConnectorCustomizers(gracefulShutdownTomcat);
        return tomcat;
    }
}
